﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.NetworkInformation;

namespace TCP_SocketDongbo
{
    class NicGrabber:BaseGrabber
    {
        public override void GetNicConfig()
        {
            var card = NetworkInterface.GetAllNetworkInterfaces().Where(x => x.OperationalStatus == OperationalStatus.Up);
            foreach (NetworkInterface nic in card)
            {
                Console.WriteLine("Network Card: {0}", nic.Description);
                Console.WriteLine("Name: {0}", nic.Name);

                //Địa chỉ vật lý
                PhysicalAddress MAC = nic.GetPhysicalAddress();
                Console.WriteLine("Dia chi MAC: {0}", MAC);

                //Địa chỉ IP và DNS
                IPInterfaceProperties ippro = nic.GetIPProperties();
                Console.WriteLine("DNS suffix: {0}", ippro.DnsSuffix);

                //Xuat dia chi DeffaultGateway
                foreach (var gateway in ippro.GatewayAddresses)
                {
                    Console.WriteLine("Default Gateway: {0}", gateway.Address);
                }
                //Xuat dia chi DNS
                foreach (var dnsaddress in ippro.UnicastAddresses)
                {
                    Console.WriteLine("IP address: {0}", dnsaddress.Address);
                }
                Console.WriteLine();
            }
        }
    }
}
